package cn.com.api.mapper;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import cn.com.api.entity.ApiGoods;
import cn.com.api.entity.ApiGoodsTopicLink;
import cn.com.api.entity.ApiGoods_p;
import cn.com.api.entity.ApiSpeicalChang;
import cn.com.api.entity.apiGoodInfo;
import cn.com.api.resultpage.GoodsPage;
import cn.com.util.PageInfo;

//DAO
public interface ApiGoodsMapper {

	// 根据条件查询商品
	List<Map<String, Object>> getGoodsByType(@Param("type_codes") List<Integer> type_codes, @Param("obj") Object obj);

	// 默认查询商品
	List<Map<String, Object>> getGoodsDef();

	// 根据id查询商品详情
	List<Map<String, Object>> getGoodsById(Object id);

	// 根据productid查询商品详情
	Map<String, Object> getGoodsByProductId(@Param("productid") String productid);

	// 搜索商品
	List<Map<String, Object>> searchGoods(@Param("name") String name, @Param("cityid") String cityid);

	// 搜索店铺
	List<Map<String, Object>> searchShops(@Param("name") String name, @Param("cityid") String cityid);

	// 图文详情
	List<Map<String, Object>> imageDetail(Object id);

	/***************************************************************************/

	public List<ApiGoods> serchGoodsByParType(@Param("par_type") int par_type);

	public List<Map<String, Object>> serchGoodsByType(@Param("type") int type, @Param("city_id") int city_id);

	public List<ApiGoods> serchGoodsByPromotionTypeListPage(@Param("type") int type, @Param("page") PageInfo pi);

	/***************************************************************************/

	public ApiGoods searchGoodsById(@Param("id") Long id);

	public List<ApiGoods> searchMyGoods(@Param("u_id") String u_id);

	public List<ApiGoods> searchMyGoodsPage(@Param("u_id") String u_id, @Param("page") PageInfo pageInfo);

	// 推荐商品
	public List<ApiGoods> tuijianGoods(@Param("type") String type, @Param("cityid") String cityid);

	public List<ApiGoods> searchGoodsByShopIdListPage(@Param("map") Map<String, Object> map,
			@Param("page") PageInfo page);

	// 根据id查看
	public ApiGoods findT_goodsById(@Param("id") Long id);

	public List<ApiGoods> findT_goodsListOrderById();

	public List<ApiGoods> searchGoodsListPage(@Param("map") Map<String, Object> conditions,
			@Param("page") PageInfo pageInfo);

	public List<Map<String, Object>> searActGoodsListPage(@Param("map") Map<String, Object> conditions,
			@Param("page") PageInfo pageinfo);

	public List<Map<String, Object>> searActGoodsByTypeListPage(@Param("map") Map<String, Object> conditions,
			@Param("page") PageInfo pageinfo);

	// erp
	public int insertT_goods4erp(ApiGoods T_goods);

	// 更新erp同步资料
	public int updateT_goods4erp(ApiGoods T_goods);

	// 添加
	public int insertT_goods(ApiGoods T_goods);

	// 修改
	public int updateT_goods(ApiGoods T_goods);

	// 删除
	public int deleteT_goods(@Param("id") Integer id);

	// 添加商品图片
	public void insertGoods_p(ApiGoods_p goods_p);

	// 商品图库
	public List<ApiGoods_p> findGoodsPByGoodsId(Long goods_id);

	// 根据店铺查商品
	public List<ApiGoods> searchGoodsByShop(int shop_id);

	/*************** syy start *********************************/
	public List<GoodsPage> searchGoodsByGoodsIds(@Param("did") Integer did,
			@Param("goods_ids") List<Integer> goods_ids);

	public List<GoodsPage> searchGoodsByOrderId(@Param("did") Integer did);

	public List<ApiGoods> searchGoodsByShopAndTypeListPage(@Param("shop_id") int shop_id, @Param("type") int type,
			@Param("page") PageInfo page);

	// 更新商品的上下架状态
	public void updateGoodsTopOrDel(Map<String, Object> map);

	// 查询店铺 某一分类下打商品数量
	public int getGoodsCountByTypeIdAndShopId(@Param("type_id") Integer type_id, @Param("shop_id") Integer shop_id);

	/*************** syy end *********************************/

	public List<Map<String, String>> searShopAllGoodsListPage(@Param("shopid") String shopid,
			@Param("page") PageInfo page);

	public List<Map<String, Object>> searMenGoods(@Param("type") String type, @Param("cityid") String cityid);

	public List<Map<String, String>> menAllGoodsListPage(@Param("page") PageInfo page, @Param("obj") String obj,
			@Param("shopid") List<String> shopid, @Param("type") String type, @Param("city_id") String city_id);

	public List<Map<String, String>> menThreeGoods(@Param("shopid") String shopid, @Param("type") String type);

	public List<ApiGoods_p> findAllGoodsPByGoodsId(Long goods_id);

	public List<Integer> searTypeByGoodsId(@Param("products") String[] pro);

	// 分享商品信息
	public Map<String, Object> shareProInfo(@Param("proid") String proid);

	public Map<String, Object> shareProDetail(@Param("proid") String proid);

	public List<Map<String, Object>> searGoodsActTypeListPage(@Param("typeid") String typeid,
			@Param("cityid") String cityid, @Param("name") String name, @Param("page") PageInfo pageInfo);

	/**
	 * 得到某个商品已购买的个数
	 * 
	 * @param goodsId
	 * @return
	 */
	public Integer getSoldedGoodsCount(@Param("goodsId") long goodsId);

	public int batchUpdateGoods(@Param("map") Map<String, Object> conditions);

	/**
	 * 查询店铺的热销产品
	 * 
	 * @param shop_id
	 * @param page
	 * @return
	 */
	public List<Map<String, Object>> searchHotSaleGoodsByShopIdListPage(@Param("shop_id") String shop_id,
			@Param("sold") Integer sold, @Param("page") PageInfo page);

	/**
	 * 更新商品
	 * 
	 * @param goods
	 * @return
	 */
	public int updateGoods(ApiGoods goods);

	public List<Map<String, Object>> getAllGoodsType();

	public LinkedList<ApiSpeicalChang> searchSpecailChangListPage(@Param("map") Map<String, Object> conditions,
			@Param("page") PageInfo pageinfo);

	public void addSpecalChang(ApiSpeicalChang apiSpeicalChang);

	public List<ApiGoods> searchScByTypeId(@Param(value = "typeId") int typeId,
			@Param(value = "topicId") String topicId, @Param(value = "flag") String flag,
			@Param(value = "userId") String userId);

	public void batchInsertTopicLink(List<ApiGoodsTopicLink> list);

	List<Map<String, Object>> getGoodInfoByCondition(Map<String, Object> conditions);

	public List<apiGoodInfo> getGoodsInfoByGoodId(final int goodId);

	List<Map<String, Object>> getGoodPicByGoodId(@Param("id") String id, @Param("type") Integer type);

	public String getGoodIdByProductId(String productId);

	public String getSaleNumByGoodId(String goodId);

	// 获取收藏的商品列表
	public List<ApiGoods> findGoodsListByFavoriteTypeListPage(@Param("user_id") String user_id,
			@Param("type") Integer type, @Param("page") PageInfo page);

}
